name: Демонстрация GitVerse CI/CD и cloud.ru Evolution Artifact Registry
on:
  push:
env:
  EVOAR_URI: test-bondarevsky.cr.cloud.ru
jobs:
  build-test:
    name: Demo build and push to Evolution Artifact Registry
    runs-on: ubuntu-latest
    container:
      image: catthehacker/ubuntu:act-latest
    steps:
      - name: Checkout to the branch
        uses: https://github.com/actions/checkout@v3
        
      - name: Set up Docker buildx
        uses: https://github.com/docker/setup-buildx-action@v1
      
      - name: Log in to Evolution Artifact Registry
        uses: https://github.com/docker/login-action@v2
        with:
          registry: ${{ env.EVOAR_URI }}
          username: ${{ secrets.EVOAR_KEYID }}
          password: ${{ secrets.EVOAR_KEYSECRET }}
      
      - name: Build and push docker image to Evolution Artifact Registry
        id: build_push
        uses: https://github.com/docker/build-push-action@v4
        with:
          push: true
          platforms: linux/amd64
          provenance: false
          tags: ${{ env.EVOAR_URI }}/helloworld:build${{ github.sha }}
          file: ./Dockerfile
          context: .

      - name: Create or Update Evolution Container App
        uses: https://github.com/CLOUDdotRu/evo-container-app-action@main
        with:
          client_id: ${{ secrets.EVOAR_KEYID }}
          client_secret:  ${{ secrets.EVOAR_KEYSECRET }}
          project_id: 06363f30-bde4-41a2-a96f-398bf8bd830e
          registry_uri: ${{ env.EVOAR_URI }}
          image_name: helloworld@${{ steps.build_push.outputs.digest }}
          name: my-simple-business-app34
          port: 8080